%% Based on a TeXnicCenter-Template by Tino Weinkauf.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[a4paper,oneside,12pt]{article}
% Alternative Options:
%	Paper Size: a4paper / a5paper / b5paper / letterpaper / legalpaper / executivepaper
% Duplex: oneside / twoside
% Base Font Size: 10pt / 11pt / 12pt


%% Normal LaTeX or pdfLaTeX? %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ==> The new if-Command "\ifpdf" will be used at some
%% ==> places to ensure the compatibility between
%% ==> LaTeX and pdfLaTeX.
\newif\ifpdf
\ifx\pdfoutput\undefined
	\pdffalse              %%normal LaTeX is executed
\else
	\pdfoutput=1           
	\pdftrue               %%pdfLaTeX is executed
\fi


%% Fonts for pdfLaTeX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ==> Only needed, if cm-super-fonts are not installed
\ifpdf
	%\usepackage{ae}       %%Use only just one of these packages:
	%\usepackage{zefonts}  %%depends on your installation.
\else
	%%Normal LaTeX - no special packages for fonts required
\fi


%% Language %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}


%% Packages for Graphics & Figures %%%%%%%%%%%%%%%%%%%%%%%%%%
\ifpdf %%Inclusion of graphics via \includegraphics{file}
	\usepackage[pdftex]{graphicx} %%graphics in pdfLaTeX
\else
	\usepackage[dvips]{graphicx} %%graphics and normal LaTeX
\fi
%\usepackage[hang,tight,raggedright]{subfigure} %%Subfigures inside a figure
%\usepackage{pst-all} %%PSTricks - not useable with pdfLaTeX


\usepackage{setspace}
%\singlespacing        %% 1-spacing (default)
\onehalfspacing       %% 1,5-spacing
%\doublespacing        %% 2-spacing


\begin{document}

\ifpdf
	\DeclareGraphicsExtensions{.pdf,.jpg,.png}
\else
	\DeclareGraphicsExtensions{.eps}
\fi

\pagestyle{plain}

\title{JFontView Swing-based Font Selection Component}
\author{Nathan C Jones, Carl Robinson}
\maketitle

\section{Introduction}

JFontView allows for easier font selection by providing a dynamic preview of the currently selected font, and the ability to store favourite fonts and quicky make comparisons between them. JFontView is available under the LGPL license\footnote{source code is available via subversion at: http://jfontview.googlecode.com/svn/trunk/}. The main features of the JFontView font selector are:

\begin{itemize}
   \item Ability to describe a font.
   \item Maintain user-defined favourites list.
   \item Editable font preview area.
   \item Context independent component can be embedded in a dialog, dockable panel etc.
   \item Resizeable.
   \item Convenient API.
\end{itemize}

JFontView requires Java runtime version 1.5 or above.


\section{Design Approach}
The main aim of the design of the font selector component is to provide the user with an instance of \texttt{java.awt.Font} - the standard class for describing a font in Java.

This type of object describes a font with just three properties: Name, Style, and Size. Thus the component only allows the user to manipulate these three aspects of the font.

Because the user requires the ability to alter the state of a font but \texttt{java.awt.Font} is immutable, a new \texttt{MutableFont} class was created to wrap an immutable font. The mutable font can return an instance of \texttt{java.awt.Font} representive of the state of the mutable font at the time it was requested. The font selector component is a natural visual extension to allow user interaction with an instance of a mutable font .

As the mutable font is being manipulated changes are reflected immediately in the preview area. This functionality is due to the use of the observer design pattern, and is accessible through the API of the \texttt{MutableFont} class. Should a developer so wish, they can add more observers to the mutable font used by the component so that other parts of their application receive notification when the state of the font has changed.

The ability to easily compare different fonts is a major use case for the component. With a long list of all system fonts a comparison is not easy. The favourite fonts list attempts to solve this problem by allowing the user to add favourite or potential fonts into a much smaller collection. Comparing fonts is made easier by the favourites list because fonts to be compared are potentially much closer in proximity than they would be in the complete alphabetic font list.

\section{Visual Guide}
An annotated screen shot of the font selector is shown in figure \ref{fig:fontSelector}. The component offers simplicity and while still providing the ability to easily select a suitable font. 

\begin{figure}
	\centering
		\includegraphics[scale=0.65]{images/fontSelectorDesc.PNG}
	\caption{Annotated screenshot showing the font selector component.}
	\label{fig:fontSelector}
\end{figure}

\section{Example Application}
The example application demonstrates how the font selector can work in a the context of a real text editor. The text editor is sparse on features, but demonstrates the use of the font selector in a modal dialog.

After typing and selecting some text in the editor pane, you can change the font of the selected text by using the edit menu and choosing "change font".

The font selector only provides a font. It is up to the application itself to decide how to use it. In this example, the application distinguishes between selected and non-selected text and either applies the font style or sets the caret font respectivly.

The font selector maintains per session favourites. After closing and re-opening the dialog the favourites list will remain the same. Extracting and storing this list of favourite fonts so that the list persists between sessions is made easy by the design of the font selector API.

\section{Future Improvements}

Favourites are displayed in table to provide consistant visual layout. It may be useful for the user to be able to edit the properties (style and size) of a favourite font from within this table.

\end{document}

